package com.weixing.mall.provider.controller.rpc;

import com.gexin.fastjson.JSON;
import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.provider.api.model.vo.ActRpcVo;
import com.weixing.mall.provider.model.domain.Activity;
import com.weixing.mall.provider.service.IActivityService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author wx
 * @Date 2020/1/9 15:07
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/act")
public class ActivityRpcController extends BaseController {

    @Autowired
    private IActivityService activityService;

    @GetMapping("selectById")
    public Result<ActRpcVo> selectById(Long actId) {
//        System.out.println("活动id：" + actId);
        Activity activity = activityService.getById(actId);
        ActRpcVo actRpcVo = null;
        if (null != activity) {
//            System.out.println("活动存在");
            actRpcVo = new ActRpcVo();
            BeanUtils.copyProperties(activity, actRpcVo);
            actRpcVo.setActIntegerType(activity.getActType());
//            actRpcVo.setActType(EnumUtil.getIEnum(ActTypeEnum.class, activity.getActType()));
        }
//        System.out.println(JSON.toJSONString(actRpcVo));
        return ResultUtil.success(actRpcVo);
    }

}
